package com.ringtheweb.model;

import static javax.persistence.GenerationType.*;

import java.io.Serializable;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.EnumType;
import javax.persistence.Enumerated;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;

import org.hibernate.annotations.Fetch;
import org.hibernate.annotations.FetchMode;

import com.ringtheweb.model.validation.PhoneNum;



@Entity
@Table(name="PHONE_NUMBER")
@PhoneNum
public class PhoneNumber implements Serializable {
	
	/**
	 * serialVersionUID
	 */
	private static final long serialVersionUID = 200L;
	
	@Id
	@GeneratedValue(strategy = AUTO)
	private Long id;
	
	@ManyToOne(fetch=FetchType.EAGER)
	@Fetch(FetchMode.JOIN)
	@JoinColumn(name="USER_ID")
	private User user;
	
	@Column(name="PHONE_NUMBER")
	private String number;
	
	@Column(name="PHONE_COUNTRY")
	@Enumerated(EnumType.STRING)
	private PhoneCountry phoneCountry;
	
	@Column(name="PHONE_TYPE")
	@Enumerated(EnumType.ORDINAL)	
	private PhoneNumberType phoneType = PhoneNumberType.ISDN;
	

	public PhoneNumber(){};
	
	
	public PhoneNumber(String number){
		this.number = number;
	}

	public String getNumber() {
		return number;
	}

	public void setNumber(String number) {
		this.number = number;
	}

	public Long getId() {
		return id;
	}


	public void setId(Long id) {
		this.id = id;
	}

	public User getUser() {
		return user;
	}

	public void setUser(User user) {
		this.user = user;
	}


	public PhoneCountry getPhoneCountry() {
		return phoneCountry;
	}


	public void setPhoneCountry(PhoneCountry phoneCountry) {
		this.phoneCountry = phoneCountry;
	}
	
	public PhoneNumberType getPhoneType() {
		return phoneType;
	}


	public void setPhoneType(PhoneNumberType phoneType) {
		this.phoneType = phoneType;
	}	
	

	
	

}
